package com.pzhu.user.domain.enums;

import com.fasterxml.jackson.annotation.JsonValue;
import com.mybatisflex.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.mapstruct.Mapping;

@AllArgsConstructor
@Getter
public enum UserSexEnum {
    man(0, "男"),
    woman(1, "女");

    @EnumValue
    @JsonValue
    private final Integer code;

    private final String name;

    public static UserSexEnum of(Integer code) {
        for (UserSexEnum e : UserSexEnum.values()) {
            if (e.getCode().equals(code)) {
                return e;
            }
        }
        return null;
    }
}
